<template>
  <basic-container :btnFlag = true>
    <div class="card-border">
      <card-header :header-data="headerData"></card-header>
      <bostech-detail :detail-data="firstTrialData"></bostech-detail>
      <div class="form-group">
        <span class="form-label" style="display:none">确认意见:</span>
        <el-radio-group v-model="radio" @change="addcontent" style="display:none">
          <el-radio  :label="1">同意</el-radio>
          <el-radio  :label="2">不同意</el-radio>
        </el-radio-group>
        <div>
          <el-input
            v-if="opcontent"
            v-model="planningListCheck.listopinion.opinion"
            style="margin-left: 142px;margin-top: 10px;width: 30%;height: 74px;"
            required="required"
            type="textarea"
            :rows="3">
          </el-input>
        </div>
      </div>
      <el-collapse v-model="activeNames" @change="handleChange" style="margin-top:2rem;">
        <el-collapse-item name="1">
          <template slot="title">
            <div class="card-header collapse-header">
              <div class="head-title collapse-title">基本信息</div>
              <div class="head-explain">
                操作说明
                <i class="el-icon-question"></i>
              </div>
            </div>
          </template>
          <bostech-detail :detail-data="detailData"></bostech-detail>
        </el-collapse-item>
        <el-collapse-item name="2">
          <template slot="title">
            <div class="card-header collapse-header">
              <div class="head-title collapse-title">规划信息</div>
              <div class="head-explain">
                操作说明
                <i class="el-icon-question"></i>
              </div>
            </div>
          </template>
          <div style="margin-top: 50px;margin-left: 10px;">
            <avue-crud
              :data="tableData"
              :option="option"
              :page="page"
              :table-loading="tableLoading"
              @on-load="getList"
              @refresh-change="refreshChange"
              style="margin-top: -60px;"
            >
              <template slot-scope="scope" slot="menu">
                <div class="menu-title" @click.stop="detailApplication(scope.row,scope.index)">
                  <i class="iconfont iconview" style="color: #409EFF;"></i>
                  <p class="menu-title-text">详情</p>
                </div>
                <!--<div class="menu-title" @click.stop="adjustment()">
                  <i class="iconfont iconalter icon-warning"></i>
                  <p class="menu-title-text">调整</p>
                </div>-->
              </template>
            </avue-crud>
          </div>
        </el-collapse-item>
      </el-collapse>
      <div class="consult-button">
        <el-button type="warning" size="small" @click.stop="ListCheck()">发改委确认</el-button>
        <el-button type="info" size="small" @click.stop="goback()">关闭</el-button>
      </div>

      <el-dialog
        title="提示"
        :visible.sync="dialogVisible1"
        width="30%"
        :before-close="handleClose">
        <span>请选择同意或不同意</span>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="dialogVisible1 = false">确 定</el-button>
        </span>
      </el-dialog>


    </div>
  </basic-container>
</template>
<script>
  import {projectRegister} from "@/api/planning/project";
  import {getbasisinfo} from "@/api/planning/detailList";
  import {listconfirm} from "@/api/planning/detailList";
  import { PROJECT_DIC } from "@/const/dict";
  export default {
    mounted() {
      this.getbasisinfo();
    },
    name: "firstTrialFor",
    data() {
      return {
        radiotemp:'',
        taskidtemp:'',
        planningListCheck:{
          listopinion:{
            needReport:'',
            approved:'',
            opinion:'退回理由:',
          },
          id:'',
        },
        infoForm:{
          title:'',
          description:'',
        },
        projectForm:{
          listId:'',
          approvingAuthorityLevel:'',
          planningLevel:'',
        },
        approvingAuthorityLevelDic:PROJECT_DIC.APPROVING_AUTHORITY_LEVEL,
        planningLevelDic:PROJECT_DIC.PLANNING_RANK,
        dialogFormVisible:false,
        dialogVisible1: false,
        headerData:{
          title:'发改委确认'
        },
        value: "",
        radio:'1',
        activeNames: ["1","2"],
        category: "A",
        opcontent:false,
        firstTrialData:[
          {label:'部门人员',value:'发改委'},
        ],
        detailData:[],
        tableData: [],
        page: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 20 // 每页显示多少条
        },
        tableLoading: false,
        option: {
          page: true,
          addBtn: false,
          editBtn: false,
          addRowBtn: false,
          indexLabel: "序号",
          index: true,
          indexWidth:70,
          cellBtn: false,
          delBtn: false,
          columnBtn: false,
          refreshBtn: false,
          filterBtn: false,
          searchBtn: false,
          keyId: "id",
          column: [
            {
              label: "规划名称",
              width: 240,
              prop: "title",
              cell: true
            },
            // {
            //   label: "规划期限",
            //   prop: "startEnd",
            //   cell: true,
            //   formatter: function (row, value, label, column) {
            //     return row.startDate + '-' + row.endDate;
            //   }
            // },
            {
              label: "申报(牵头)单位",
              prop: "orgCode",
              type: "select",
              dicData: PROJECT_DIC.ORG_CODE,
              cell: true
            },
            {
              label: "发布层级",
              prop: "approvingAuthorityLevel",
              type: "select",
              dicData:PROJECT_DIC.APPROVING_AUTHORITY_LEVEL,
              cell: true
            },
            {
              label: "规划等级",
              prop: "planningRank",
              type: "select",
              dicData: PROJECT_DIC.PLANNING_RANK,
              cell: true
            }
          ]
        },

        infosrules: {
          approvingAuthorityLevel: [
            { required: true, message: "请输入发布层级", trigger: "blur" }
          ],
          planningLevel: [
            { required: true, message: "请输入规划层级", trigger: "blur" }
          ],
        },




      };
    },
    methods: {
      handleChange(val) {
      },
      getList(page, params) {
      },
      refreshChange() {
        this.getList(this.page);
      },
      addcontent(){
        if (this.radio=="2"){
          this.opcontent=true;
          this.radiotemp=false;
        }
        if (this.radio=="1"){
          this.opcontent=false;
          this.radiotemp=true;
        }

      },
      goback(){
        this.$router.go(-1);
      },

      adjustment(){
        this.dialogFormVisible = true;
      },
      cancelDept(){
        this.dialogFormVisible = false;
      },
      detailApplication(row, index){
        let src = `/regDetail/detail/${row.registerinfoId}`;
        this.$router.push({
          path: src
        })
      },
      getbasisinfo(){
        getbasisinfo(this.$route.query.listId).then(response => {
          this.infoForm.title=response.data.data.title;
          this.infoForm.description=response.data.data.description;
          this.detailData = [{label: '清单标题', value:this.infoForm.title },{label: '清单说明', value:this.infoForm.description, newline: true }];
          this.tableData=response.data.data.planningRegisterinfoList;
          this.taskidtemp=response.data.data.taskId;
        })
      },
      ListCheck(){
        this.radiotemp=true;
        if(this.radio == ''){
          //用于没有点击同意或者不同意时的提醒
          this.dialogVisible1 = true;
        }else{
          this.planningListCheck.listopinion.approved = this.radiotemp;
          this.planningListCheck.id = this.taskidtemp;
          this.$confirm("确定提交审核吗?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          }).then(() => {
            // 提交代码

            listconfirm(this.planningListCheck).then(response => {
              if(response.data.code == 0){
                this.$notify({
                  title: '成功',
                  message: '审核成功',
                  type: 'success',
                  duration: 2000
                });
                this.$router.go(-1);
              }
            })
          });

        }
      },


      handleClose(done) {
        this.$confirm('确认关闭？')
          .then(_ => {
            done();
          })
          .catch(_ => {});
      },
      handleClose2(done) {
        this.$confirm('确认关闭？')
          .then(_ => {
            done();
          })
          .catch(_ => {});
      },

    }
  };
</script>

<style lang="scss" scoped>
  .text {
    font-size: 14px;
  }

  .item {
    margin-bottom: 18px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both;
  }

  .box-card {
    margin-top: 20px;
    width: 480px;
  }
  .head-title {
    color: rgb(2, 2, 2);
    text-align: left;
    display: inline;
    font-weight: 600;
  }
  .collapse-title{
    font-size:1rem;
  }
  .head-explain {
    color: #333;
    text-align: left;
    display: inline;
    font-size: 14px;
    font-weight: 600;
  }
  .form-group {
    padding: 20px;
  }
  .form-label {
    font-weight: 600;
    display: inline-block;
    width: 140px;
  }
  .collapse-header {
    display: inline-block;
    width: 94%;
  }

  .consult-button {
    margin: 2rem 0;
    text-align: center;
  }
</style>
